const event = {
  eventList: [],
  listen: function () {
    let [key, fn] = [...arguments]
    if ('function' !== typeof fn) {
      console.log('请添加订阅事件')
      return
    }
    if (!this.eventList[key]) {
      this.eventList[key] = []
    }
    this.eventList[key].push(fn)
  },
  trigger: function () {
    let [key, ...args] = [...arguments]
    let event = this.eventList[key]
    event.forEach(fn => {
      fn.apply(this, args)
    })
  }
}

event.listen('click', function (name, times) {
  console.log(`${ name } clicked ${ times } times~`)
})

event.listen('move', function (name) {
  console.log(`Pls d't move, Mr.${ name }`)
})

event.trigger('click', 'Yeoman', 20)
event.trigger('move', 'Yeoman')
